<template>
	<view class="black">
		<!-- <image src="http://122.152.205.72:88/superhero/MARVEL/Venom/cover.jpg" mode="widthFix" class="cover"></image> -->
		<image :src="cover" mode="widthFix" class="cover" @longpress="operator"></image>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cover: ""
			}
		},
		onLoad(params) {
			var cover = params.cover
			this.cover = cover
			//通过api获取导航栏属性
			uni.setNavigationBarColor({
				frontColor: "#ffffff",
				backgroundColor: "#000000"
			})
		},
		
		methods: {
			operator(){
				var me = this
				uni.showActionSheet({
					itemList: ["保存图片到本地"],
					success: function(res){
						if(res.tapIndex == 0){
							// console.log('进入下载')
							uni.showLoading({
								title:"图片保存中..."
							})
							uni.downloadFile({
								url: me.cover,
								success(result) {
									var tempFilePath = result.tempFilePath
									// console.log(tempFilePath)
									uni.saveImageToPhotosAlbum({
										filePath:tempFilePath,
										success() {
											uni.showToast({
												title:"保存成功",
												duration:2000
											})
										},
										complete() {
											uni.hideLoading()
										}
									})
								}
							})
						}
					}
				})
			}
		}
	}
</script>

<style scoped>
.black {
	background-color: #000000;
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
	justify-content: center;
	position: fixed;
}
.cover {
	align-self: center;
}
</style>
